package com.wonders.framework.auto.builder.code.convert.instance;

import com.wonders.framework.auto.builder.code.convert.BaseTagConvert;
import com.wonders.framework.auto.builder.code.entity.vo.BuildColumn;
import com.wonders.framework.auto.builder.code.entity.vo.BuildTable;

/**
 * 实体方法标签转换器
 * 
 * @author WuBin
 * 
 */
public class EntityFunctionConvert extends BaseTagConvert {

	@Override
	public String convert(String str, String tag, BuildTable buildTable) {
		String prefix = super.getPrefix(str, tag);
		str = "";
		for (int i = 0; i < buildTable.getColumns().size(); i++) {
			BuildColumn buildColumn = buildTable.getColumns().get(i);
			str += prefix + "public " + buildColumn.getTypeName() + " get"
					+ buildColumn.getFunctionName() + "() {";
			str += "\n";
			str += prefix + "  return " + buildColumn.getPropertyName() + ";";
			str += "\n";
			str += prefix + "}";
			str += "\n";
			str += "\n";
			str += prefix + "public void set" + buildColumn.getFunctionName()
					+ "(" + buildColumn.getTypeName() + " "
					+ buildColumn.getPropertyName() + ") {";
			str += "\n";
			str += prefix + "  this." + buildColumn.getPropertyName() + " = "
					+ buildColumn.getPropertyName() + ";";
			str += "\n";
			str += prefix + "}";
			str += "\n";
			if (i + 1 != buildTable.getColumns().size()) {
				str += "\n";
			}
		}
		return str;
	}

}
